///*
// *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
// *
// *  Redistribution and use in source and binary forms, with or without
// *  modification, are permitted provided that the following conditions are met:
// *
// *  Redistributions of source code must retain the above copyright notice,
// *  this list of conditions and the following disclaimer.
// *  Redistributions in binary form must reproduce the above copyright
// *  notice, this list of conditions and the following disclaimer in the
// *  documentation and/or other materials provided with the distribution.
// *  Neither the name of the dreamlu.net developer nor the names of its
// *  contributors may be used to endorse or promote products derived from
// *  this software without specific prior written permission.
// *  Author: Chill 庄骞 (smallchill@163.com)
// */
//package com.plian.system.controller.hr.passport;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.plian.Tools.Func;
//import com.plian.Tools.StringPool;
//import com.plian.Tools.TokenUtil;
//import com.plian.Tools.base.BaseController;
//import com.plian.Tools.pagedata.PageData;
//import com.plian.system.config.Resubmit;
//import com.plian.system.constant.sys.FormStatusConstant;
//import com.plian.system.constant.sys.FormTypeConstant;
//import com.plian.system.entity.hr.passport.PassportManagement;
//import com.plian.system.model.CommonCode;
//import com.plian.system.model.ListResult;
//import com.plian.system.model.R;
//import com.plian.system.mybatis.search.SearchEntity;
//import com.plian.system.mybatis.search.SearchParamEntiy;
//import com.plian.system.mybatis.support.Condition;
//import com.plian.system.mybatis.support.Query;
//import com.plian.system.service.hr.passport.IPassportManagementService;
//import com.plian.system.service.sys.code.IFormCodeService;
//import com.plian.system.service.wf.FormWorkflowService;
//import com.plian.system.vo.hr.passport.PassportManagementVO;
//import com.plian.system.wrapper.hr.passport.PassportManagementWrapper;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.web.bind.annotation.*;
//
//import javax.validation.Valid;
//import java.util.HashMap;
//import java.util.List;
//
///**
// *  控制器
// *
// * @author gangan
// * @since 2019-12-02
// */
//@Slf4j
//@RestController
//@AllArgsConstructor
//@RequestMapping("api/passportmanagement")
//public class PassportManagementController extends BaseController {
//
//	private IPassportManagementService passportManagementService;
//
//	private FormWorkflowService formWorkflowService;
//
//	private IFormCodeService formCodeService;
//
//	private PassportManagementWrapper passportManagementWrapper;
//
//    /**
//    * 详情
//    */
//	@PostMapping("/detail")
//	public R<PassportManagementVO> detail(@Valid @RequestBody PassportManagement passportManagement) {
//		PassportManagement detail = passportManagementService.getOne(Condition.getQueryWrapper(passportManagement));
//		PassportManagementVO passportManagementVO = passportManagementWrapper.entityToVO(detail);
//		return R.data(passportManagementVO);
//	}
//
//	/**
//	* 分页
//	*/
//	@PostMapping("/list")
//	public ListResult<PassportManagementVO> list(@Valid @RequestBody Query query) {
//		if(query.getAscs()==null&&query.getDescs()==null){
//			query.setDescs("create_time");
//		}
//		List<SearchEntity> entityList = query.getSearch();
//		QueryWrapper<PassportManagement> queryWrapper = SearchParamEntiy.getQueryWrapper(
//				Condition.getQueryWrapper(new PassportManagement()), entityList
//		);
//		queryWrapper.eq("create_company_id", TokenUtil.getTokenOrgId());
//		IPage<PassportManagement> pages = passportManagementService.page(Condition.getPage(query), queryWrapper);
//		List<PassportManagementVO> passportManagementVOS = passportManagementWrapper.entityToVO(pages.getRecords());
//		ListResult<PassportManagementVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//		listResult.setList(passportManagementVOS);
//		listResult.setTotal(Long.valueOf(pages.getTotal()).intValue());
//		return listResult;
//	}
//
//	/**
//	* 新增或修改
//	*/
//	@PostMapping("/submit")
//	@Resubmit(delaySeconds = 0)
//	public R submit(@Valid @RequestBody PassportManagement passportManagement) {
//		if (passportManagement.getId()==null){
//			passportManagement.setVersion("1");
//			passportManagement.setIsInLibrary(2);
//			passportManagement.setCode(formCodeService.getCode(FormTypeConstant.HR_PASSPORT_MANAGEMENT_FORM));
//			passportManagement.setFormType(String.valueOf(FormTypeConstant.HR_PASSPORT_MANAGEMENT_FORM));
//		}
//		boolean result = passportManagementService.saveOrUpdate(passportManagement);
//		HashMap<String, Object> processVariable = new HashMap<>();
//		formWorkflowService.startProcessAndSimulate(String.valueOf(passportManagement.getId()),passportManagement.getFormType(),processVariable);
//
//		return result ? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//	}
//
//	/**
//	* 删除
//	*/
//	@PostMapping("/remove")
//	public R remove(@RequestBody PageData pd) {
//		List<String> ids = (List<String>)pd.get("ids");
//		return passportManagementService.deleteLogic(Func.toLongList(StringUtils.join(ids, StringPool.COMMA)))
//				? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//	}
//
//	/**
//	 * 归还
//	 */
//	@PostMapping("/reback")
//	public R reback(@RequestParam PageData pd) {
//		String id = (String)pd.get("id");
//		return passportManagementService.reback(Long.valueOf(id))
//				? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//	}
//
//	/**
//	 * 分页
//	 */
//	@PostMapping("/refList")
//	public ListResult<PassportManagementVO> refList(@Valid @RequestBody Query query) {
//		if(query.getAscs()==null&&query.getDescs()==null){
//			query.setDescs("create_time");
//		}
//		List<SearchEntity> entityList = query.getSearch();
//		QueryWrapper<PassportManagement> queryWrapper = SearchParamEntiy.getQueryWrapper(
//				Condition.getQueryWrapper(new PassportManagement()), entityList
//		);
//		queryWrapper.lambda().eq(PassportManagement::getCompanyNameId, TokenUtil.getTokenOrgId());
//		queryWrapper.lambda().eq(PassportManagement::getStatus, FormStatusConstant.FINISH);
//		queryWrapper.lambda().eq(PassportManagement::getIsInLibrary, 2);
//		IPage<PassportManagement> pages = passportManagementService.page(Condition.getPage(query), queryWrapper);
//		List<PassportManagementVO> passportManagementVOS = passportManagementWrapper.entityToVO(pages.getRecords());
//		ListResult<PassportManagementVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//		listResult.setList(passportManagementVOS);
//		listResult.setTotal(Long.valueOf(pages.getTotal()).intValue());
//		return listResult;
//	}
//
//}
